package com.yuanchu.search.controller;

import com.yuanchu.common.utils.PageResult;
import com.yuanchu.common.utils.R;
import com.yuanchu.search.dto.QueryOrderParamsDto;
import com.yuanchu.search.entity.YoshopOrderRefundEntity;
import com.yuanchu.search.service.OrderRefundService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2024-03-02 1:56
 */
@RestController
@RequestMapping("order/refund")
public class OrderRefundController {

    @Resource
    private OrderRefundService orderRefundService;

    @ApiOperation(value = "/order/refund/list&dataType=all&page=1", tags = "查询商家售后订单列表")
    @GetMapping("/list")
    public R geStoreOrderList(QueryOrderParamsDto param) {
        // 根据dataType和page获取用戶订单列表数据
        PageResult<YoshopOrderRefundEntity> orderList = orderRefundService.queryStoreOrderRefunds(param);
        Map<String, Object> map = new HashMap<>();
        map.put("list", orderList);
        return R.ok().put("data", map);
    }

    @ApiOperation(value = "/order/refund/detail&orderId=3", tags = "查询售后订单详情")
    @GetMapping("/detail")
    public R getStoreOrderDetail(@RequestParam Integer orderRefundId) {
        YoshopOrderRefundEntity orderDetail = orderRefundService.getStoreOrderDetail(orderRefundId);
        Map<String, Object> detail = new HashMap<>();
        detail.put("detail", orderDetail);
        return R.ok().put("data", detail);
    }

}
